<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    function ReadExcel() {
        //C:\Users\dengtao\Desktop\翼支付美妆类目搜索单品 - 副本.xlsx
        var tempStr = "";
        //得到文件路径的值
        var filePath = document.getElementById("upfile").value;

        //创建操作EXCEL应用程序的实例
        var oXL = new ActiveXObject("Excel.application");
        //打开指定路径的excel文件
        var oWB = oXL.Workbooks.open(filePath);
        //操作第一个sheet(从一开始，而非零)
        oWB.worksheets(1).select();
        var oSheet = oWB.ActiveSheet;
        //使用的行数
        var rows = oSheet.usedrange.rows.count;
        try {
            for (var i = 2; i <= rows; i++) {
                if (oSheet.Cells(i, 2).value == "null" || oSheet.Cells(i, 3).value == "null") break;
                var a = oSheet.Cells(i, 2).value.toString() == "undefined" ? "" : oSheet.Cells(i, 2).value;
                //tempStr += ('<li><a href="/item/get/'+ oSheet.Cells(i, 2).value + ' ' + oSheet.Cells(i, 3).value + ' ' + oSheet.Cells(i, 4).value + ' ' + oSheet.Cells(i, 5).value + ' ' + oSheet.Cells(i, 6).value + "\n");

                tempStr += ('<li><a href="/item/get/' + oSheet.Cells(i, 2).value + '"><p class="picl">');
                tempStr += ('<img data-original="' + oSheet.Cells(i, 6).value + '" src="/js/grey.gif"/></p>');
                tempStr += ('<p class="txtr"><span class="sptop"><i>国内发货</i></span><span class="smidd">' + oSheet.Cells(i, 4).value + '</span>');
                tempStr += ('<span class="sbtom"><b>￥</b><i>' + oSheet.Cells(i, 5).value + '</i></span></p></a></li>\n');

            }
        } catch (e) {
            document.getElementById("txtArea").value = tempStr;
        }
        document.getElementById("txtArea").value = tempStr;
        //退出操作excel的实例对象
        oXL.Application.Quit();
        //手动调用垃圾收集器
        CollectGarbage();
    }
</script>
<input type="file" id="upfile" value=""/><input type="button" onclick="ReadExcel();" value="read">
<textarea id="txtArea" cols=200 rows=50></textarea>

</body>
</html>
